using System;
using System.Data;

namespace LocalBoard.Persistence
{
	/// <summary>
	/// Summary description for DataConverter.
	/// </summary>
	public class DataConverter
	{
		public static int GetInteger(object value)
		{
			if(value == DBNull.Value)
				return 0;
			return Convert.ToInt32(value);
		}

		public static string GetString(object value)
		{
			if(value == DBNull.Value)
				return "";
			return value.ToString().Trim();
		}

		public static DateTime GetDateTime(object value)
		{
			if(value == DBNull.Value)
				return DateTime.MinValue;
			return Convert.ToDateTime(value);
		}

		public static bool GetBool(object value)
		{
			if(value == DBNull.Value)
				return false;
			return Convert.ToBoolean(value);		
		}
	}
}
